# coding: utf-8
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter, QPaintEvent, QLinearGradient, QColor
from PySide6.QtWidgets import QApplication, QWidget


class MyWidget(QWidget):
    def paintEvent(self, event: QPaintEvent):
        painter = QPainter(self)
        linear_gradient = QLinearGradient(0, 0, self.width(), self.height())
        linear_gradient.setColorAt(0.0, QColor('#9708cc'))
        linear_gradient.setColorAt(1.0, QColor('#364fc7'))

        painter.setPen(Qt.PenStyle.NoPen)
        painter.setBrush(linear_gradient)
        painter.drawRect(self.rect())


if __name__ == '__main__':
    app = QApplication([])
    w = MyWidget()
    w.show()
    app.exec()
